package com.cskaoyan.jdbc.crud;

import com.cskaoyan.jdbc.utils.JDBCUtils;
import java.sql.*;

/**
 * 创建日期: 2022/05/12 16:38
 *
 * @author ciggar
 */
public class QueryJDBCDemo2 {

    public static void main(String[] args) throws SQLException {


        Connection connection = JDBCUtils.getConnection();

        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("select * from stu");

        while (resultSet.next()) {

            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            int age = resultSet.getInt("age");
            String className = resultSet.getString("class");

            System.out.println("id:" + id);
            System.out.println("name:" + name);
            System.out.println("age:" + age);
            System.out.println("className:" + className);

        }

        JDBCUtils.close(connection,statement,resultSet);


    }
}
